package com.java.base.string;

import java.nio.charset.StandardCharsets;

public class StringTest {

    public static void main(String[] args) {
        String s = "𐁄";

        System.out.println(s.charAt(0));
        System.out.println(s.charAt(1));
    }

    public static void test() {
        String a = "a";
        String b = "b";
        String c = new StringBuilder().append("a").append("b").toString();
        String c1 = new StringBuilder().append("a").append("b").toString();
        String d = new StringBuilder().append(a).append(b).toString();
        String d1 = new StringBuilder().append(a).append(b).toString();
        String e = "ab";
        String e1 = a + b;
        String e2 = "a" + b;
        String e3 = "a" + "b";

        System.out.println(System.identityHashCode(c));
        System.out.println(System.identityHashCode(c1));
        System.out.println(System.identityHashCode(d1));
        System.out.println(System.identityHashCode(d));
        System.out.println(System.identityHashCode(e));
        System.out.println(System.identityHashCode(e1));
        System.out.println(System.identityHashCode(e2));
        System.out.println(System.identityHashCode(e3));
    }


    public static void test1() {
        String a = "aa";
        String a1 = "aaa".substring(0, 2);
        String a2 = "a" + "a";
        String a3 = "a" + 'a';
        String a4 = new String("a") + 'a';
        String a5 = new String("aa");

        System.out.println(System.identityHashCode(a));
        System.out.println(System.identityHashCode(a1));
        System.out.println(System.identityHashCode(a2));
        System.out.println(System.identityHashCode(a3));
        System.out.println(System.identityHashCode(a4));
        System.out.println(System.identityHashCode(a5));

    }

}

